<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <h1><?=lang('menu_cpgl')?></h1>
      <?=$this->breadcrumb->generateHTML();?>
    </div>
  </div>
  <div class="container-fluid">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-list"></i><?=lang('menu_wllb')?></h3>
      </div>
      <div class="panel-body">
        <div class="well" style="padding:0 19px;">
          <div class="row">
            <form action="<?= blang_url('orders/Order_parts/') ?>" method="post" name="searchform">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label">order_num/sku/partsName</label>
                        <input class="form-control" name="keyword" value="<?= $keyword ?>" size="28" placeholder="order_num/sku/partsName"/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label">status</label>
                        <select class="form-control" name="status" id="statusId">
                            <option value="">--<?= lang('public_qxz') ?>--</option>
                            <option value="1" <?= $optStatus[1] ?> > Normal</option>
                            <option value="2" <?= $optStatus[2] ?> > pending</option>
                            <option value="3" <?= $optStatus[3] ?> > wait purchase</option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-4 form-group" style="padding-top:37px;">
                     <input type="submit" name="searchSubmit" class="btn btn-primary" style="margin: 0 10px 0 0;" value="<?=lang('pcm_ss')?>">
                    <a href="<?= $outputUrl ?>" class="btn btn-oms"><i class="fa fa-download"></i>&nbsp;<?=lang('public_dcexcel')?></a>
                </div>
            </form>
            
          </div>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-hover oms-table">
              <thead>
                <tr>
                  <td class="text-left"><?= lang('order_wxdh') ?></td>
                  <td class="text-left">维修状态</td>
                  <td class="text-left"><?= lang('peijian_pjmc') ?></td>
                  <td class="text-left">sku</td>
                  <td class="text-left"><?= lang('peijian_sl') ?></td>
                  <td class="text-left"><?= lang('peijian_sj') ?></td>
                  <td class="text-right"><?= lang('peijian_bj') ?></td>
                  <td class="text-right"><?= lang('order_zt') ?></td>
                  <td class="text-right">site</td>
                  <td class="text-right"><?= lang('order_rq') ?></td>
                  <td class="text-right"><?= lang('order_clr') ?></td>
                  <td class="text-right">操作</td>
                </tr>
              </thead>
              <tbody>
                <?php if ($dataList): foreach ($dataList as $key => $rs): ?>
                <tr>
                <td class="text-left"><?= $rs['order_num'] ?></td>
                <td class="text-left"><?= $rs['pStatusName'] ?></td>
                <td class="text-left" title="<?= $rs['name'] ?>"><?= $rs['nameSub'] ?></td>
                <td class="text-left"><?= $rs['sku'] ?></td>
                <td class="text-left"><?= $rs['quantity'] ?></td>
                <td class="text-left"><?= $rs['price'] ?></td>
                <td class="text-right"><?= $rs['rate_price'] ?></td>
                <td class="text-right">
                    <?php
                    switch ($rs['sap_status']) {
                        case '4':
                            echo "<span style='color: #FF0099'>已取消</span>";
                            break;
                        case '5':
                            echo "<span style='color: #FF0099'>深圳已到货</span>";
                            break;
                        case '7':
                            echo "<span style='color: #FF0099'>无法采购</span>";
                            break;
                        case '8':
                            echo "<span style='color: #FF0099'>延迟到货</span>";
                            break;
                        case '9':
                            echo "<span style='color: #FF0099'>深圳已发货</span>";
                            break;
                        case '12':
                            echo "<span style='color: #FF0099'>海外已入库</span>";
                            break;
                        default:
                            echo $rs['statusName'];
                            break;
                    }
                    ?>
                </td>
                <td class="text-right"><?= $rs['point'] ?></td>
                <td class="text-right"><?= $rs['add_time'] ?></td>
                <td class="text-right"><?= $rs['add_user'] ?></td>
                <td class="text-right">
                    <?php if ($rs['is_sync']) { ?>
                        <span style="color: #1872a2">已同步</span>
                    <?php }
                    else { ?>
                        <a class="btn btn-primary btn-sm" onclick="btnCreate('<?= blang_url('orders/Order_parts/artificialCreatePartsNeed/?id=' . $rs['id'] . '&keyword=' . $keyword) ?>')"
                           href="javascript:void(0)">强行采购</a>
                    <?php } ?>
                    <?php if ($rs['sap_status'] == 4) { ?>
                        <span style="color: #FF0099">已取消</span>
                    <?php }
                    else { ?>
                        <a onclick="btnCancelPur('<?= blang_url('orders/Order_parts/cancelPurchase/?id=' . $rs['id'] . '&keyword=' . $keyword) ?>')"
                           href="javascript:void(0)" title="取消采购" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>

                    <?php } ?>
                </td>
            </tr>
                <?php endforeach; else:?>
                    <tr><th colspan="12" class="emptyNumber"><?=lang('public_mygdsj')?>....</th></tr>
                <?php endif; ?>
            </tbody>
            </table>
            <?php if($show_pages):?>
            <div class="page">
                <?=$show_pages?>
            </div>
            <?php endif;?>
          </div>
      </div>
    </div>
    </div>

    <script type="text/javascript">

    btnCreate = function (dt) {
        $.get(dt, function (data) {
            if (data.status == '1') {
                alert("成功！");
                window.location.href = location.href;
            } else {
                alert(data.msg);
            }
        }, "json");
    }

    btnCancelPur = function (dt) {
        $.get(dt, function (data) {
            if (data == '1') {
                alert("取消配件需求成功！");
                window.location.href = location.href;
            } else {
                alert("不存在该配件需求！");
            }

        }, "text");
    }
</script>
</div>
